function [l1SpiritImages, trueImage] = l1spirit_qmt_pipeline(Rfactor, WorkspaceMat)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here



%% Setup Study
%

mt_study_info

%% Load Raw Data
%

switch seqType
    case 'uk'
        [mrprot, mdh, fid] = rdMeas(rawDataFilename);
        rawKSpace = reorder_raw_siemens_mridata(fid,mdh,'mt');
end




numFE=size(rawKSpace,1);
numPE=size(rawKSpace,2);
numMT=size(rawKSpace,4);
numChannel=size(rawKSpace,5);

%% Undersample k-space
%

mask = createUndersampleMask(mask_flag,underSampleMethod,Rfactor,numPE,numFE);

% Pre-allocate array
l1SpiritImages=zeros(numFE,numPE,numMT);
trueImage=zeros(numFE,numPE,numMT);

for ii=1:numMT
    DATA=squeeze(rawKSpace(:,:,1,ii,:));

    cd('/Users/mathieuboudreau/Work/Projects/qmt_compsens/qmt_l1_spirit')
    
    [im_sqr,im_pocsspirit_sqr] = qmt_l1_spirit_pocs(DATA,mask);

    l1SpiritImages(:,:,ii)=im_pocsspirit_sqr;
    trueImage(:,:,ii)=im_sqr;
end
cd('/Users/mathieuboudreau/Work/Projects/qmt_compsens/qmt_l1_spirit')


for ii=1:numMT

    result(ii) = nRMSE(trueImage(:,:,ii),l1SpiritImages(:,:,ii));
    
end

%figure(),imagesc(l1SpiritImages(:,:,1))
%figure(),imagesc(trueImage(:,:,1))

plot(result)

save(WorkspaceMat)

%%
%




end

